Structuring Element

Morphological operations are based around a kernel, which represents the shape and size of the neighborhood that will be sampled when calculating the pixel values to be modified. The basic idea is that a window of some finite size and shape — the kernel — is scanned across the image. The output pixel value is the weighted sum of the input pixels within the window where the weights are the values assigned to every pixel of the window itself.

Various standard kernels are provided for morphological operations and the size and the shape of the kernel determine the characteristics of the operation. A simple 5 x 5 structuring element and the shapes available for 2D interpretation are shown below.

Simple structuring elements

Simple structuring elements

You should note that the size of the neighborhood controls the strength of the applied operator.

An important issue that arises within the convolution process centers on the fact that the convolution kernel will extend beyond the borders of the image when it is applied to border pixels. A common approach to dealing with border effects is to pad the original image with extra rows and columns based on the filter size. The technique used in Dragonfly to remedy border effects is to reflect the image at the borders. For example, column[-1] = column [1], column [-2] = column [2], and so on.